
    function hasClass(elements,cName){ // 判断是否含有某个class
        if(elements.className.match(new RegExp( "(\\s|^)" + cName + "(\\s|$)") ))
            return true;
        else
            return false;
    }
    function addClass(elements,cName){ // 添加class
        if( !this.hasClass( elements,cName ) ){
            elements.className += " " + cName;
        };
    }

    function removeClass(elements,cName){  // 移除某个class
        if( this.hasClass( elements,cName ) ){
            elements.className = elements.className.replace( new RegExp( "(\\s|^)" + cName + "(\\s|$)" )," " );
        }
    }
    function updateOrderInfo(){
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange=function (){
            if(xhr.readyState == 4 && xhr.status == 200){
                //将用户填写的信息获取过来
                var cardNum = document.getElementById("cardNum");
                var expiryDate = document.getElementById("expiryDate");
                var firstName = document.getElementById("firstName");
                var lastName = document.getElementById("lastName");
                var address1 = document.getElementById("address1");
                var address2 = document.getElementById("address2");
                var city = document.getElementById("city");
                var state = document.getElementById("state");
                var zip = document.getElementById("zip");
                var country = document.getElementById("country");
            }
            xhr.open("get","conFirmOrderForm",true);
            xhr.send();
        }
    }

function doAjax(){
    //1.创建异步对象
    var xhr = new XMLHttpRequest();
    //2.绑定事件
    xhr.onreadystatechange = function (){
        if(xhr.readyState == 4 && xhr.status == 200){
            //更新dom对象
            var a = document.getElementById("showOrder");
            var b = document.getElementById("button");
            //document.getElementById("enter").disabled=true;
            removeClass(a,'hidden');
            addClass(b,'hidden');

            //document.querySelectorAll("input.enter");

            var list = document.getElementsByClassName('enter');
            var i;

            for (i = 0; i < list.length; ++i)
            {
                    list[i].readOnly="true";
            }

            //处理数据
            //var data = xhr.responseText;
            //document.getElementById("scardNum").innerText=data;
        }
    }
    //3.初始请求的参数：请求的方式，请求的地址，
    xhr.open("get","viewOrder",true);
    //4.发起请求
    xhr.send();
}

function showShippingPage(){
    var a = document.getElementById("showShippingAddress");
    removeClass(a,'hidden');
}